import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-04-01
 * Time: 13:58
 */
public class Test {
    public static void main(String[] args) {
        int[][] array = new int[2][];//行必须要写，列可以不写
        array[0] = new int[]{1,2,3,4,5};
        array[1] = new int[]{2,3,4,5,6,7,8,9,0,10};

        for(int i=0;i<array.length;i++){
            for(int j=0;j<array[i].length;j++){
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
    }

    public static void main5(String[] args) {
        int[][] array = {{1, 2, 3}, {4, 5, 6}, {1, 5, 8, 0, 3}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }

        System.out.println("==========================");
        for (int[] arr : array) {
            for (int x : arr) {
                System.out.print(x + " ");
            }
            System.out.println();
        }

        System.out.println("==========================");
        System.out.println(Arrays.deepToString(array));
    }

    public static void main4(String[] args) {
        // 二维数组
        int[][] array = {{1, 2, 3}, {4, 5, 6}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }

        int[][] array1 = new int[][]{{1, 2, 3}, {4, 5, 6}};
    }

    public static boolean func1(int[] array) {
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                count++;
                if (count == 3) {
                    return true;
                }
            } else {
                count = 0;
            }
        }

        return false;
    }

    public static void main3(String[] args) {
        //判断数组中是否有三个连续的奇数
        int[] array = {2, 3, 5, 8, 10, 12};
        boolean res = func1(array);
        System.out.println(res);
    }

    public static void swap(int[] array, int left, int right) {
        int tmp = array[left];
        array[left] = array[right];
        array[right] = tmp;
    }

    public static void reverse(int[] array) {
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            swap(array, left, right);
            left++;
            right--;
        }
    }

    public static void main2(String[] args) {
        int[] array = {8, 9, 3, 4, 1};
        reverse(array);
        System.out.println(Arrays.toString(array));
    }

    public static int[] findTarget(int[] array, int Target) {
        int[] res = {-1, -1};
        for (int i = 0; i < array.length; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] + array[j] == Target) {
                    res[0] = i;
                    res[1] = j;
                }
            }
        }

        return res;
    }

    public static void main1(String[] args) {
        int[] array = {10, 5, 3, 1, 9};
        int Target = 10;
        int[] res = findTarget(array, Target);
        System.out.println(Arrays.toString(res));
    }
}
